#include<iostream>
#include"complex0.h"

MyComplex MyComplex::operator+(const MyComplex& z) const
{
	return MyComplex(this->real + z.real, this->imag + z.imag);
}

MyComplex MyComplex::operator-(const MyComplex& z) const
{
	return MyComplex(this->real - z.real, this->imag - z.imag);
}

MyComplex MyComplex::operator*(const MyComplex& z) const
{
	double A = this->real, C = z.real;
	double B = this->imag, D = z.imag;
	return MyComplex(A*C-B*D,A*D+B*C);
}

MyComplex::~MyComplex()
{
}

MyComplex operator*(const double a, const MyComplex& z)
{
	return MyComplex(a * z.real, a * z.imag);
}

MyComplex operator~(const MyComplex& z)
{
	return MyComplex(z.real,-z.imag);
}

std::ostream& operator<<(std::ostream& os, const MyComplex& z)
{
	os << "(" << z.real << ", " << z.imag << "i)";
	return os;
}

bool operator>>(std::istream& is, MyComplex& z)
{
	std::cout << "real:";
	if (!(is >> z.real))	return false;
	std::cout << "imag:";
	if (!(is >> z.imag))	return false;
	return true;
}



